<?php

//set plugin id as file name of plugin
$plugin_id = basename(__FILE__);

//some plugin data
$data['name']   = "Contact Form Plugin";
$data['desc']   = "To send direct mail to the Post author";
$data['author'] = "John";
$data['url']    = "http://hardkap.net";

//register plugin to SHP
register_plugin($plugin_id, $data);

function contact_function1() {
  global $theme_main, $optionValue, $scriptName, $theme_post, $authorsEmail;
  $author = $theme_post['author'];
  switch ($optionValue) {
    case "submit":
        $theme_main['content']  = "Thank you!";
        $theme_main['content'] .= "<br>Your mail has been sent to the post author<br>";
        break;
    default:
        $theme_main['content']  = "<h3>Email the Author</h3>";
        $theme_main['content'] .= '<form method="post" action="'.$scriptName.'/pluginFunction2/submit">';
        $theme_main['content'] .= '<p><label for="email">Your Email Id:</label>&nbsp;&nbsp;<input id="email" name="email" type="text"></p>';
        $theme_main['content'] .= '<p><label for="message">Message:</label>&nbsp;&nbsp;:<textarea id="message" name="id2" cols="20" rows="5"></textarea></p>';
        $theme_main['content'] .= '<p><input type="submit" value="Send Message"></p>';
        $theme_main['content'] .= '</form>';
        break;
  }
}

function contact_function2() {
  global $theme_main, $scriptName, $theme_post;
  $theme_post['loc_footer'] .= '<a href="'.$scriptName.'/pluginFunction2">Contact Author</a>';
}

//add hook, where to execute a function
add_hook($plugin_id, 'hook-pluginFunction2','contact_function1');
add_hook($plugin_id, 'hook-post','contact_function2');


?>